<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        :root {
            --bg: #000;
            --fontSize: 25px;
        }

        .pink-theme {
            --bg: hotpink;
        }

        body {
            transition: background 1s;
            background: var(--bg);
        }

        button {
            position: fixed;
            top: 50%;
            left: 50%;
            transition: color 1s;
            transform: translate(-50%, -50%);
            padding: 20px;
            border: none;
            background: #fff;
            font-size: var(--fontSize);
            color: var(--bg);
        }
    </style>
</head>

<body>
    <button>点击切换</button>
    <script>
        document.querySelector("button").addEventListener("click", () => {
            if (document.body.classList.contains("pink-theme")) {
                document.body.classList.remove("pink-theme");
            } else {
                document.body.classList.add("pink-theme");
            }
        });
    </script>
</body>

</html>